class Solution(object):
    def maximumRemovals(self, s, p, removable):
        m = len(p)
        n = len(s)
        def cal(k):
            if k == 0:
                return True
            else:
                a_set = set(removable[:k])
                left = 0
                right = 0
                while left < n and right < m:
                    if left not in a_set and s[left] == p[right]:
                        left += 1
                        right += 1
                    else:
                        left += 1
                return right == m

        left = 0
        right = len(removable)
        while left < right:
            mid = (left + right + 1) // 2
            if cal(mid):
                left = mid
            else:
                right = mid - 1
        return left
